using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bridge : MonoBehaviour
{
    public float downSpeed = 0.1f;
    public float downDistance = 5;
    public string targetName;


    Rigidbody2D rb;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }


    public void Down()
    {        
        rb.velocity = new(0, -downSpeed);
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        if(collision.gameObject.name.Equals(targetName))
            rb.velocity = new(0, 0);
    }    
}
